using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DailyTransaction
{
    class BAO_Rcpt
    {
        private DAO_Rcpt dao = new DAO_Rcpt();
        internal string get_newID()
        {
            string  newID = "";
            
            DataTable tbl = dao.get_newID();
            if (tbl.Rows.Count > 0)
            {
                newID = tbl.Rows[tbl.Rows.Count - 1][0].ToString();
                if (newID == "")
                {
                    newID = "0";
                }
            }
            else
                newID = "0";
            return newID;
        }

        internal int insert_new_receptionist(string id, string name)
        {
            return dao.insert_new_receptionist(id, name);
        }

        public DataTable get_lst_Receptionist()
        {
            return dao.get_lst_Receptionist();
        }

        internal DataTable getData(string pComcode)
        {
            string sql = "select KIND_PMENT,COMP_SUNCD,COMP_NAME,COMP_CREAT,ACC_CRE_MED,ACC_CRE_SERV,ACC_CRE_DRUG,"
                        + "ACC_CRE_DISP,T0_code,T4_code,ADA,SAMA"
                        + " from comtbl left join ab_account_code "
                        + " ON (COMP_SUNCD=ACC_DEB) "
                        + " where comp_code = '" + pComcode + "'";
            return dao.executeQuery(sql);
        }

        internal int insertNewData(string pCompcode, string pCompName, string pCompSUNC, 
                                    string pKindPmnt, string pMed, string pServ, string pT0, 
                                    string pT4, string pDisp, string pDrug, string pCreateD, 
                                    bool pAda, bool pSama)
        {
            return dao.insert_new_company(pCompcode.Trim(), pCompName.Trim(), pCompSUNC.Trim(),
                            pKindPmnt.Trim(), pMed.Trim(), pServ.Trim(), pT0.Trim(),
                            pT4.Trim(), pDisp.Trim(), pDrug.Trim(), pCreateD, pAda, pSama);
        }

        internal int Update_Kind_Pmnt_Desc()
        {
            return dao.Update_Kind_Pmnt_Desc();
        }

        internal DataTable get_lst_company()
        {
            string sql = "select COMP_CODE,KIND_PMENT,COMP_SUNCD,COMP_NAME,COMP_CREAT,ACC_CRE_MED,ACC_CRE_SERV,ACC_CRE_DRUG,"
                       + "ACC_CRE_DISP,T0_code,T4_code,ADA,SAMA"
                       + " from comtbl left join ab_account_code "
                       + " ON (COMP_SUNCD=ACC_DEB) "
                       + " order by COMP_CODE";
            return dao.executeQuery(sql);
        }
        internal int update_data(string pCompcode, string pCompName, string pCompSUNC,
                                    string pKindPmnt, string pMed, string pServ, string pT0,
                                    string pT4, string pDisp, string pDrug, string pCreateD,
                                    bool pAda, bool pSama)
        {
            return dao.update_data(pCompcode.Trim(), pCompName.Trim(), pCompSUNC.Trim(),
                            pKindPmnt.Trim(), pMed.Trim(), pServ.Trim(), pT0.Trim(),
                            pT4.Trim(), pDisp.Trim(), pDrug.Trim(), pCreateD, pAda, pSama);
        }
    }
}
